count( ) Function is used to specify the number of times an element is present in the List.
Let us say, we have a List that contains three names, 'Mohan', 'Kriti' and 'Salim'. And we want to find how many times 'Mohan' is present in the List.
x = ["Mohan", "Kriti", "Mohan", "Salim"] y = x.count("Mohan") print("The count of Mohan is ",y)
So, in the above code we have created a 'List' and initialised to the variable 'x'.
Below is how the values are positioned in the List,
Now, if we see the above diagram, 'Mohan' is present '2' times in the above List.
And the 'count( )' Function is used to find how many times 'Mohan' is present.
And we get the below output,